words = ['hello', 'world', 'python', 'list']

# 按长度排序
words.sort(key=len)
print(words)
# Output:['list', 'hello', 'world', 'python']

# 按最后一个字母排序
words.sort(key=lambda word: word[-1])
print(words)
# Output:['world', 'python', 'hello', 'list']

# 逆序
words.sort(reverse=True)
print(words)
# Output:['world', 'python', 'list', 'hello']


a = [1,2,3,4,5,6,7,1,2,3]
# 查找位置
idx = a.index(3)  # 第一个3的位置
count = a.count(3)  # 3出现的次数
print(count)
# Output:2